//
//  View2.m
//  IOS深入传值
//
//  Created by 江湖 on 2020/6/10.
//  Copyright © 2020 江湖. All rights reserved.
//

#import "View2.h"
#import "UIViewController+Agent.h"
#import "AgentDelegate.h"

@interface View2()
@property(nonatomic,weak)id <AgentDelegate> delegate;
@end
@implementation View2

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame: frame]) {
        self.backgroundColor = [UIColor yellowColor];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
        btn.frame =CGRectMake(10, 10, 50, 20);
        btn.backgroundColor = [UIColor grayColor];
        [btn setTitle:@"点击" forState:0];
        [btn setTitleColor:[UIColor whiteColor] forState:0];
        [self addSubview:btn];
        [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

- (void)btnClick{
//    走代理
    self.delegate = [UIViewController getCurrentVC];
    [self.delegate agentFunc1];

}
@end
